﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;
using VSTranslator.Translation;
using Microsoft.VisualStudio.Text;


namespace VSTranslator.Adornment
{
    [Export(typeof(IWpfTextViewCreationListener))]
    [ContentType("text")]
    [TextViewRole(PredefinedTextViewRoles.Document)]
    public sealed class Connector : IWpfTextViewCreationListener
    {
        public void TextViewCreated(IWpfTextView textView)
        {
            TranslationAdornmentManager.Create(textView);
        }

        static public void Execute(IWpfTextView view, TranslationRequest request)
        {			
			TranslationAdornmentManager manager = view.Properties.GetProperty<TranslationAdornmentManager>(typeof(TranslationAdornmentManager));           
            manager.AddTranslation(view.Selection.SelectedSpans[0], request);
			request.GetTranslationAsync();
        }

        [Export(typeof(AdornmentLayerDefinition))]
        [Name("TranslationAdornmentLayer")]
        [Order(After = PredefinedAdornmentLayers.Caret)]
		[Order(After = PredefinedAdornmentLayers.Outlining)]
		[Order(After = PredefinedAdornmentLayers.Selection)]
		[Order(After = PredefinedAdornmentLayers.Squiggle)]
		[Order(After = PredefinedAdornmentLayers.Text)]
		[Order(After = PredefinedAdornmentLayers.TextMarker)]		
        public AdornmentLayerDefinition TranslationLayerDefinition;
    }
}
